import 'package:email_validator/email_validator.dart';
import 'package:inmotion_pro/config/const.dart';

class CheckUtil {
  // true
  static bool checkMixinIsTure(dynamic value) {
    return value != null && (value == true || value == 1 || value == "1");
  }

  // 邮箱是否有效
  static bool checkMixinIsEmailValid(String email) {
    return email.isNotEmpty && EmailValidator.validate(email);
  }

  // 手机号是否有效
  static bool checkMixinIsPhoneValid(String phone) {
    return phone.isNotEmpty && RegExp(r'^[1][3-9]\d{9}$').hasMatch(phone);
  }

  // 密码是否有效
  static bool checkMixinIsPasswordValid(String password) {
    return password.isNotEmpty && password.length >= passwordMinLength;
  }

  // 验证码是否有效
  static bool checkMixinIsVerifyCodeValid(String code) {
    return code.isNotEmpty && code.length == verificationCodeLength;
  }
}
